#include "canbus/message.h"

/**
 * @namespace canbus
 * @brief canbus
 */
namespace canbus {

/**
 * @class CanMsg17
 * @brief Concrete can message that stores part of the wheel angle information
 */
class CanMsg17: public CanMsg {
public:
  CanMsg17():
  CanMsg(),
  wheel_angle_rl(0),
  wheel_angle_rr(0),
  wheel_angle_rrl(0),
  wheel_angle_rrr(0) 
  {}

  CanMsg17(uint8_t* value): 
  CanMsg(value),
  wheel_angle_rl(0),
  wheel_angle_rr(0),
  wheel_angle_rrl(0),
  wheel_angle_rrr(0) 
  {}

  virtual ~CanMsg17() = default;

  void UpUpdateData() {
    wheel_angle_rl  = -1*Deg2Rad*(ParseTwins(*(data_+1), *(data_+0)) - offset)/unit;
    wheel_angle_rr  = -1*Deg2Rad*(ParseTwins(*(data_+3), *(data_+2)) - offset)/unit; 
    wheel_angle_rrl = -1*Deg2Rad*(ParseTwins(*(data_+5), *(data_+4)) - offset)/unit;
    wheel_angle_rrr = -1*Deg2Rad*(ParseTwins(*(data_+7), *(data_+6)) - offset)/unit;
  }

  template <typename T>
  void DownUpdateData(const T& input_data) {}

  static const int32_t ID;
  static const std::string NAME;

  double wheel_angle_rl;
  double wheel_angle_rr;
  double wheel_angle_rrl; 
  double wheel_angle_rrr; 

  const int offset = 5000;
  const int unit = 100;

  friend class CanbusHandler;
};

}